<script>
	<?php 
	/*$_SESSION['RF']["subfolder"]="commbook/".'<script>document.write($("#student_sid").val());</script>'.'/'; */?>
//	alert('<?php /* echo "ASDF".$_SESSION['RF']["subfolder"]; */?>');
 
	
	function cancel(){
		window.close();
	}
	function save(){
		$("#frmTahunAjaran").submit();		
	}
	
	function Change_sid(){ 
//		window.parent.showLoader();	
		$filter = {"is_active":1,"student_id":$("#student_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VStudentKelasTahunAjaran",filter: $filter,value_field:"sid",title_field:"sid"   },
			success: function(data) {
				printConsole(data.length+'--'  + "data1");
//				fillSelectData("#walikelas_id",data);	
				if(data.length==0){
				$("#student_sid").val(0);}
				else
				{$("#student_sid").val(data[0].value);}	
			url=window.location.href+'&student_sid='+$("#student_sid").val()+'&student_id='+$("#student_id").val();
			window.location.replace(url);
//			alert(url);
//				alert (data[0].value);		
//				reloadPage();
			},
			complete:function(){
//				window.parent.hideLoader();
			}
		});	
}			
</script>

<style>
table tr td 
{
font-size:12px;
} 
table.message
{
border-collapse:collapse;
}
table.message, tr, td
{
border: 1px solid black;font-size:12px;
vertical-align: top;
}
</style>

<div style="border-bottom:2px solid #000;padding-bottom:5px;margin-bottom:20px">
<?php 
	$this->widget('application.components.widgets.ActionBar', 
		array("menuAlign" => "right", 
			'items' => array(
				array(
					'id' => "btnRefresh",
					'title' => "Simpan",
					'icon' => "images/action/Actions-document-save-all-icon.png",
					'callback'=>"save"
				),					
				array(
					'id' => "btnCancel",
					'title' => "Batal",
					'icon' => "images/action/Actions-dialog-cancel-icon.png",
					'callback'=>"cancel"
				),
			)
		)
	);
?>
</div>

<script type="text/javascript">

	$(function(){
		tinymce.init({
			selector: "textarea",theme: "modern",width: 680,height: 100,
		    plugins: [
		         "advlist autolink link image lists charmap print preview hr anchor pagebreak",
		         "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
		         "table contextmenu directionality emoticons paste textcolor responsivefilemanager"
		   ],
		   toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
		   toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor  | print preview code ",
		   image_advtab: true ,
		   menubar: false,		   
		   external_filemanager_path:"<?php echo Yii::app()->request->baseUrl; ?>/filemanager/",
		   filemanager_title:"Responsive Filemanager" ,
		   external_plugins: { "filemanager" : "<?php echo Yii::app()->request->baseUrl; ?>/filemanager/plugin.min.js"}			          
		});
	});
</script>

<form id="frmTahunAjaran" action="index.php?r=karyawan/commbook/commbook/edit" method="POST">	
	<input type="hidden" name="op" value="<?php echo $op ?>" readonly/>
	<input type="hidden" name="id" id="id" value="<?php echo $id ?>" readonly/>
	<input type="hidden" id="kelas_tahun_ajaran_id" name="kelas_tahun_ajaran_id" value="<?php echo $kelas_tahun_ajaran_id ?>"/>
	<input type="hidden" id="karyawan_id" name="karyawan_id" value="<?php echo $karyawan_id ?>"/>       
  	<input type="hidden" id="student_sid" name="student_sid" value="<?php echo $student_sid ?>"/>   
  	<input type="hidden" id="subject" name="subject" value="<?php echo $subject ?>"/>            
    

<?php

 
 


echo $data_view;  
$_SESSION['RF']["subfolder"]="commbook/".$student_sid.'/';
?>
<?php if ($id==0) { ?>    
	 
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Student") ?></label>	
		<select name="student_id" id="student_id" onChange="Change_sid()">
			<?php
				foreach ($students as $student){
					$selected = $student_id == $student["student_id"] ? "selected" : "";				
					echo"<option value='$student[student_id]' $selected>$student[name]</option>";
				}
			?>
		</select>
	</div>	 
 
<div>
	<label class="form mandatory" style="width:100px"> <?php echo Yii::t("label","Title") ?></label> 	
<input id="subject" name="subject" />
</div>
<?php } else { ?>
  	<input type="hidden" id="student_id" name="student_id" value="<?php echo $student_id ?>"/>  
<?php } ?>
<div>
	<label class="form mandatory" style="width:100px"> <?php echo Yii::t("label","Message") ?></label> 	
<textarea id="message" name="message"></textarea>
</div>
</form>

